

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using JTC.MiniCommerce.Core;
using JTC.MiniCommerce.Localization;
using SubSonic.Utilities;

namespace JTC.MiniCommerce.Web.admin.controls.sitesettings {
  public partial class browsinglog : SiteSettingsControl {
  
    #region Member Variables
    
    private string view = string.Empty;
    
    #endregion
  
    #region Page Events

    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e) {
      try {
        view = Utility.GetParameter("view");
        if (pnlSettings.Visible) {
          SetBrowsingLogProperties();
          if (!Page.IsPostBack) {
            chkBrowsingCategory.Checked = SiteSettings.CollectBrowsingCategory;
            chkBrowsingProduct.Checked = SiteSettings.CollectBrowsingProduct;
            chkCollectSearchTerms.Checked = SiteSettings.CollectSearchTerms;
          }
        }
      }
      catch (Exception ex) {
        Logger.Error(typeof(browsinglog).Name + ".Page_Load", ex);
        base.MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message));
      }
    }

    /// <summary>
    /// Handles the Click event of the btnSave control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void btnSave_Click(object sender, EventArgs e) {
      try {
        SiteSettings.CollectBrowsingCategory = chkBrowsingCategory.Checked;
        SiteSettings.CollectBrowsingProduct = chkBrowsingProduct.Checked;
        SiteSettings.CollectSearchTerms = chkCollectSearchTerms.Checked;
        base.Save(SiteSettings);
      }
      catch (Exception ex) {
        Logger.Error(typeof(browsinglog).Name + ".Page_Load", ex);
        base.MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message));
      }
    }
    
    
    #endregion

    #region Methods

    #region Private

    /// <summary>
    /// Sets the browsing log properties.
    /// </summary>
    private void SetBrowsingLogProperties() {
      this.Page.Title = LocalizationUtility.GetText("titleSiteSettingsBrowsingLog");
      pnlSettings.GroupingText = LocalizationUtility.GetText("pnlBrowsingLog");
      LocalizationUtility.AddLabelText(lblBrowsingCategory);
      LocalizationUtility.AddHoverHelp(hlBrowsingCategoryHelp);
      LocalizationUtility.AddLabelText(lblBrowsingProduct);
      LocalizationUtility.AddHoverHelp(hlBrowsingProductHelp);
      LocalizationUtility.AddLabelText(lblCollectSearchTerms);
      LocalizationUtility.AddHoverHelp(hlCollectSearchTermsHelp);
      LocalizationUtility.AddButtonText(btnSave);
    }

    #endregion

    #endregion

  }
}